::=============================================
::==                Assassins                ==
::==             by Bryan Smith              ==
::==                6/20/2011                ==
::=============================================

IF not "%1"=="" (
	@echo on
) else (
	@echo off
)
cls
title Assassins

::=============================================
::==               Variables
::=============================================
set /a location=1
set object[1]=arrows=0
set object[2]=key=5
set object[3]=rock=1
set object[4]=bow=0
set object[5]=chalice=10
set /a time=1
set /a b2Door=0
set /a b3GuardsSleep=0
set /a b3GuardsAlive=1
set /a d3GuardsAlive=1
set /a d3Stage=1
set /a chance=16384
set /a hasArrows=1
set /a hasBow=1
set /a hasRock=0
set /a hasKey=0
set /a maxInv=3
set /a currentInv=2
set choice=
set back=


::=============================================
::==                Menu
::=============================================
:MENU
cls
echo  #####################################################################
echo ##                                                                   ##
echo ##     @@@    @@@    @@@    @@@    @@@    @@@   @@  @     @   @@@    ##
echo ##    @   @  @      @      @   @  @      @          @@    @  @       ##
echo ##    @@@@@   @@@    @@@   @@@@@   @@@    @@@   @@  @  @  @   @@@    ##
echo ##    @   @      @      @  @   @      @      @  @@  @    @@      @   ##
echo ##    @   @   @@@    @@@   @   @   @@@    @@@   @@  @     @   @@@    ##
echo ##                                                                   ##
echo #######################################################################
echo ##                                                                   ##
echo ##      Choice an option:                                            ##
echo ##              1) New Game                                          ##
echo ##              2) Load Game                                         ##
echo ##              3) About                                             ##
echo ##              4) Exit                                              ##
echo ##                                                                   ##
echo  #####################################################################
set /p choice="--->"
goto MENUCHOICE

::=============================================
::==                MENUCHOICE
::=============================================
:MENUCHOICE
if "%choice%" == "1" goto START
if "%choice%" == "2" (
	if exist SavedGameState.save (
		goto LOAD
	) else (
		echo.
		echo No save game exists!
		echo.
		pause
	)
)
if "%choice%" == "3" goto ABOUT
if "%choice%" == "4" goto END
goto MENU

::=============================================
::==                Beginning
::=============================================
:START
cls
echo -------------------------------+ Assassins +---------------------------------
echo.
echo You are a professional assassin hired by a greedy and evil noble.
echo Your job is to obtain a magical artifact. This artifact, known to some
echo as a myth, is rumored to give the wielder the power to conquer all 
echo who stand in defiance. You have been on the hunt for months; clues
echo have led you to a secret underground dungeon that is heavily guarded.
echo Your mission is to look for the artifact while remaining undetected. 
echo If guards detect you, you will be captured or killed. Dispatch the guards
echo in silence and make your way through the dungeon.
echo.
echo You jump down from a sewage drain into a cold, dark, room.
echo.
pause
goto EnterLocation1

::=============================================
::==                 ACTION
::=============================================
:ACTION
echo.
set action=
set verb=
set obj=
set back=return3
goto CheckforChalice
:return3
set /p action="--->"
echo.
for /f "tokens=1,2 delims= " %%a in ("%action%") do set verb=%%a&set obj=%%b
goto CHECKACTION

::=============================================
::==              CHECKACTION
::=============================================
:CHECKACTION
if "%verb%" == "take" goto TAKE
if "%verb%" == "drop" goto DROP
if "%verb%" == "look" goto LOOK
if "%verb%" == "go" goto GO
if "%verb%" == "inv" goto INV
if "%verb%" == "throw" goto THROW
if "%verb%" == "wait" goto WAIT
if "%verb%" == "kill" goto KILL
if "%verb%" == "open" goto OPEN
if "%verb%" == "exit" goto end
if "%verb%" == "save" goto SAVE
if "%verb%" == "load" goto LOAD
if "%verb%" == "help" goto HELP
echo You do not have the ability to do that.
echo.
goto ACTION

::=============================================
::==              Help
::=============================================
:HELP
echo You are a professional assassin, you do not need help.
echo.
goto ACTION

::=============================================
::==                 CheckforChalice
::=============================================
:CheckforChalice
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	if "%%b" == "chalice" (
		if "%%c" == "0" (
			goto WINGAME
		)
	)
	if "%%b" == "arrows" (
		if "%%c" == "0" (
			set /a hasArrows=1
		) else (
			set /a hasArrows=0
		)
	)
	if "%%b" == "bow" (
		if "%%c" == "0" (
			set /a hasBow=1
		) else (
			set /a hasBow=0
		)
	)
	if "%%b" == "rock" (
		if "%%c" == "0" (
			set /a hasRock=1
		) else (
			set /a hasRock=0
		)
	)
		if "%%b" == "key" (
		if "%%c" == "0" (
			set /a hasKey=1
		) else (
			set /a hasKey=0
		)
	)
)
goto %back%

::=============================================
::==                 TAKE
::=============================================
:TAKE
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	if "%obj%" == "%%b" (
		if "%%c" == "%location%" (
			if %currentInv% LSS %maxInv% (
				echo.
				echo You take the %obj%
				set %%a=%%b=0
				set /a currentInv+=1
				goto ACTION
			)
			echo You do not have room in you inventory for that.
			echo.
			goto ACTION
		)
	)
	if "%obj%" == "" echo.&echo You need to specify what to take.&goto ACTION
)
echo You do not see a %obj% here.
echo.
goto ACTION

::=============================================
::==                 DROP
::=============================================
:DROP
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	if "%obj%" == "%%b" (
		if "%%c" == "0" (
			echo.
			echo You drop the %obj%
			set %%a=%%b=%location%
			set /a currentInv-=1
			goto ACTION
		)
	)
	if "%obj%" == "" echo.&echo You need to specify what to drop.&goto ACTION
)
echo You do not have a %obj%.
echo.
goto ACTION

::=============================================
::==                LOOK
::=============================================
:LOOK
if %location% EQU 1 (
	echo You are in a small room that appers to have served as a prison cell
	echo or torture chamber. There seems to be a exit to the east.
	echo.
	goto CheckForEvents
)
if %location% EQU 2 (
	echo You are in a narrow hallway, there appears to be a door far to the south
	echo and a room to the west
	echo.
	goto CheckForEvents
)
if %location% EQU 3 (
	echo You are at the end of the narrow hallway.
	echo.
	goto CheckForEvents
)
if %location% EQU 4 (
	echo You are in a room that shows signs of inhabitance. There is a small campfire and
	echo bedrolls with various food items and beer.There is a exit to the south and east.
	echo.
	goto CheckForEvents
)
if %location% EQU 5 (
	echo You are in a small room that appears to be used as a storage closet. There is a
	echo room to the west.
	echo.
	goto CheckForEvents
)
if %location% EQU 6 (
	echo You are at a narrow hallway that splits in two directions, to the west appears
	echo to be a room, and to the east a cornor in the hallway. There is also a room to
	echo the north.
	echo.
	goto CheckForEvents
)
if %location% EQU 7 (
	echo This is a small empty room. Something seems strange here.
	echo.
	goto CheckForEvents
)
if %location% EQU 8 (
	echo You are at the cornor of the hallway. Appears to be a large room to the north
	echo and to the west goes back down the hallway.
	echo.
	goto CheckForEvents
)
if %location% EQU 9 (
	echo This is a large room, with fortified stone walls and pillars.
	echo.
	goto CheckForEvents
)
if %location% EQU 10 (
	echo This room is plated in gold, with rubies and diamonds implanted into the
	echo obsidian framework.
	echo.
	goto CheckForEvents
)
goto ACTION

::=============================================
::==                 GO
::=============================================
:GO
if "%obj%" == "north" (
	if %location% EQU 1 echo There is a wall here, you cannot go through it.
	if %location% EQU 2 echo There is a wall here, you cannot go through it.
	if %location% EQU 3 goto EnterLocation2
	if %location% EQU 4 goto EnterLocation3
	if %location% EQU 5 echo There is a wall here, you cannot go through it.
	if %location% EQU 6 goto EnterLocation4
	if %location% EQU 7 echo There is a wall here, you cannot go through it.
	if %location% EQU 8 (
		if %d3GuardsAlive% EQU 1 (
			echo You walk into the room an are quickly spotted by the guards and a fight
			echo begins.
			echo.
			set back=return2
			set /a chance=30000
			goto RANDOMDEATH
			:return2
			set /a d3Stage=4
			set /a d3GuardsAlive=0
			pause
		)
		goto EnterLocation9
	)
	if %location% EQU 9 echo There is a door here. you may need to open it.
	if %location% EQU 10 echo There is a wall here, you cannot go through it.
	goto ACTION
)
if "%obj%" == "south" (
	if %location% EQU 1 echo There is a wall here, you cannot go through it.
	if %location% EQU 2 goto EnterLocation3
	if %location% EQU 3 (
		if %b2Door% equ 1 goto EnterLocation4
		echo There is a door here. You may need to open it.
	)
	if %b3GuardsAlive% equ 0 (if %location% EQU 4 goto EnterLocation6)
	if %b3GuardsAlive% equ 1 (
		if %location% EQU 4 (
		
			echo In your attempts to go to the hallway to the south, you trip over one of the
			echo guards shields, awakening them and a vicious fight ensues.
			echo.
			set back=return4
			set /a chance=25000
			goto RANDOMDEATH
			:return4
			set /a b3GuardsAlive=0
		)
	)
	if %location% EQU 5 echo There is a wall here, you cannot go through it.
	if %location% EQU 6 echo There is a wall here, you cannot go through it.
	if %location% EQU 7 echo There is a wall here, you cannot go through it.
	if %location% EQU 8 echo There is a wall here, you cannot go through it.
	if %location% EQU 9 goto EnterLocation8
	if %location% EQU 10 goto EnterLocation9
	goto ACTION
)
if "%obj%" == "east" (
	if %location% EQU 1 goto EnterLocation2
	if %location% EQU 2 echo There is a wall here, you cannot go through it.
	if %location% EQU 3 echo There is a wall here, you cannot go through it.
	if %location% EQU 4 (
		if %b3GuardsAlive% equ 1 (
			echo In your attempts to go to the room to the east, you awaken one of the
			echo guards, he alerts the other guard and they charge at you.
			echo.
			set back=return5
			set /a chance=25000
			goto RANDOMDEATH
			:return5
			set /a b3GuardsAlive=0
		)
		goto EnterLocation5
	)
	if %location% EQU 5 echo There is a wall here, you cannot go through it.
	if %location% EQU 6 goto EnterLocation8
	if %location% EQU 7 goto EnterLocation6
	if %location% EQU 8 echo There is a wall here, you cannot go through it.
	if %location% EQU 9 echo There is a wall here, you cannot go through it.
	if %location% EQU 10 echo There is a wall here, you cannot go through it.
	goto ACTION
)
if "%obj%" == "west" (
	if %location% EQU 1 echo There is a wall here, you cannot go through it.
	if %location% EQU 2 goto EnterLocation1
	if %location% EQU 3 echo There is a wall here, you cannot go through it.
	if %location% EQU 4 echo There is a wall here, you cannot go through it.
	if %location% EQU 5 goto EnterLocation4
	if %location% EQU 6 goto EnterLocation7
	if %location% EQU 7 echo There is a wall here, you cannot go through it.
	if %location% EQU 8 goto EnterLocation6
	if %location% EQU 9 echo There is a wall here, you cannot go through it.
	if %location% EQU 10 echo There is a wall here, you cannot go through it.
	goto ACTION
)
if "%obj%" == "" echo You need to specify a direction to go.&goto ACTION
echo You try as hard as you can to go %obj%, but you never make any progress.
goto ACTION

::=============================================
::==                INV
::=============================================
:INV
echo =======[ Inventory ]=========
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	if "%%c" == "0" (
		echo %%b
	)
)
echo.
goto ACTION

::=============================================
::==               THROW
::=============================================
:THROW
if "%obj%" == "rock" (
	if %hasRock% EQU 1 (
		if %location% EQU 8 (
			echo You throw the rock into the room ahead. The guards hear the rock and
			echo you hear them start to talk. You manage to hear one say it was 
			echo probably nothing. One stays behind while the other walks into the
			echo darkness to investigate.
			echo.
			set object[3]=rock=9
			set /a currentInv-=1
			set /a d3Stage=2
			goto ACTION
		) ELSE (
			echo You throw the rock a small distance.
			echo.
			set object[3]=rock=%location%
			set /a currentInv-=1
			goto ACTION
		)
	)
)
if "%obj%" == "" echo You need to specify what to throw.&goto ACTION
echo You do not have a %obj% to throw.
goto ACTION

::=============================================
::==                KILL
::=============================================
:KILL
if "%obj%" == "guard" (
	if %b3GuardsAlive% equ 1 (
		if %b3GuardsSleep% equ 1 (
			if %location% equ 4 (
				if %hasArrows% EQU 1 (
					echo You use the tip of one of your arrows to slice the throats of the two guards as
					echo they sleep.
					echo.
					set /a b3GuardsAlive = 0
					goto ACTION
				) 
				echo You do not have anything to kill them with.
				goto ACTION
			)
		)
	)
	
	if %d3GuardsAlive% equ 1 (
		if %hasArrows% EQU 1 (
			if %hasBow% EQU 1 (
				if %d3Stage% equ 2 (
					if %location% equ 8 (
						echo As you watch the guard wonder in the darkness, you draw back an arrow into your
						echo bow. As you hear the yew fletched bow and arrows moan under the stress you let
						echo your arrow go. In an instant the arrow flies toward the guard, hitting him
						echo in the nostral area of the nose, continuing through the skull it severs the
						echo brain stem. He is dead before his body hits the ground. The other guard
						echo did not seem to notice anything.
						echo.
						set /a d3Stage=3
						goto ACTION
					)
				)
				if %d3Stage% equ 3 (
					if %location% equ 8 (
						echo You aim for the long distance shot with your bow. Its a difficult shot.
						if %random% lss 24000 (
							set /a d3Stage=4
							set /a d3GuardsAlive=0
							echo You watch as the arrow hits him right in the right temple. 
							echo He ragdolls to the floor. You walk on in to the room.
							echo.
							pause
							goto EnterLocation9
						) else (
							echo You watch as the arrow just barly misses his head, slamming into the wall near
							echo him. The guard, startled, traces the direction the arrow came from and chases
							echo toward you. You and the guard engage in battle.
							echo.
							set /a chance=20000
							set back=return1
							goto RANDOMDEATH
							:return1
							set /a d3Stage=4
							set /a d3GuardsAlive=0
							echo You walk on in to the room.
							echo.
							pause
							goto EnterLocation9
						)
						goto ACTION
					)
				)
			) else (
			 		echo You do not have any way to shoot your arrows.
					goto ACTION
			)
		) else (
			echo You do not have any arrows.
			goto ACTION
		)
	)
)
if "%obj%" == "guards" (
	if %b3GuardsAlive% equ 1 (
		if %b3GuardsSleep% equ 1 (
			if %location% equ 4 (
				if %hasArrows% EQU 1 (
					echo You use the tip of one of your arrows to slice the throats of the two guards as
					echo they sleep.
					echo.
					set /a b3GuardsAlive = 0
					goto ACTION
				) 
				echo You do not have anything to kill them with.
			)
		)
	)
)

if "%obj%" == "" (
	echo You need to specify what to kill.
	echo.
	goto ACTION
)
echo Kill what?
echo.
goto ACTION

::=============================================
::==               WAIT
::=============================================
:WAIT
echo.
echo Time passes.
set /a time+=1
echo.
goto ACTION

::=============================================
::==               OPEN
::=============================================
:OPEN
if "%obj%" == "door" (
	if %location% EQU 3 (
		if %time% GTR 1 (
			echo.
			echo You quietly open the door, making sure not to awaken any guards. And enter the
			echo room.
			echo.
			set /a b3GuardsSleep=1
			set /a b2Door=1
			pause
			goto EnterLocation4
		) else (
			echo.
			echo You slowly open the door, only to see two guards rushing toward you.
			echo Although outnumbered you engage them.
			echo.
			set back=return6
			set /a chance=29000
			goto RANDOMDEATH
			:return6
			set /a b3GuardsAlive=0
			set /a time=2
			set /a b2Door=1
			pause
			goto EnterLocation4
		)
	)

	if %location% EQU 9 (
		if %hasKey% EQU 1 (
			echo You open the large stone door using the iron key.
			echo.
			pause
			goto EnterLocation10
		)else (
			echo No matter how hard you try the door will not open. Maybe you need
			echo something to open it.
			echo.
		)
	)
) else (
	if "%obj%" == "" (
		echo You need to specify what to open.
	) else (
		echo There is not a %obj% to open.
	)
)
goto ACTION

::=============================================
::==               EnterLocation1
::=============================================
:EnterLocation1
set /a location = 1
echo.
echo               You are in:
echo ______[]   Dungeon Room - A1    []______
echo.
goto LOOK


::=============================================
::==               EnterLocation2
::=============================================
:EnterLocation2
set /a location = 2
echo.
echo               You are in:
echo ______[]   Hallway - B1    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation3
::=============================================
:EnterLocation3
set /a location = 3
echo.
echo               You are in:
echo ______[]   Hallway - B2    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation4
::=============================================
:EnterLocation4
set /a location = 4
echo.
echo               You are in:
echo ______[]   Dungeon Room - B3    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation5
::=============================================
:EnterLocation5
set /a location = 5
echo.
echo               You are in:
echo ______[]   Closet - C3    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation6
::=============================================
:EnterLocation6
set /a location = 6
echo.
echo               You are in:
echo ______[]   Hallway Crossroad - B4    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation7
::=============================================
:EnterLocation7
set /a location = 7
echo.
echo               You are in:
echo ______[]   Dungeon Small Room - A4    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation8
::=============================================
:EnterLocation8
set /a location = 8
echo.
echo               You are in:
echo ______[]   Hallway Cornor - D4    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation9
::=============================================
:EnterLocation9
set /a location = 9
echo.
echo               You are in:
echo ______[]   Fortified Dungeon Room - D3    []______
echo.
goto LOOK

::=============================================
::==               EnterLocation10
::=============================================
:EnterLocation10
set /a location = 10
echo.
echo               You are in:
echo ______[]  Treasure Room - D2    []______
echo.
goto LOOK

::=============================================
::==               CheckForEvents
::=============================================
:CheckForEvents
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	if "%%c" == "%location%" (
		
		echo There is a %%b lying here.
		echo.
	)
)
if %b3GuardsAlive% equ 1 (
	if %b3GuardsSleep% equ 0 (
		if %location% equ 3 (
			echo You hear the mumbling of some indivduals from a near room, you can barly
			echo understand what they are saying but you manage to overhear one say 
			echo "Going to get some sleep."
			echo.
		)
	)
	if %b3GuardsSleep% equ 1 (
		if %location% equ 4 (
			echo There are two guards asleep on the bedrolls.
			echo.
		)
	)
)

if %b3GuardsAlive% equ 0 (
	if %location% equ 4 (
		echo You see the lifeless bodies of two guards.
		echo.
	)
)
if %d3GuardsAlive% equ 0 (
	if %location% equ 9 (
		echo You see the lifeless bodies of two guards.
		echo.
	)
) else (
	if %location% equ 8 (
		if %d3Stage% EQU 3 echo You see one guard alive, and another dead in the next room.
		if %d3Stage% lss 3 echo You see two guards in the room ahead.
		echo.
	)
)

goto ACTION

::=============================================
::==               SAVE
::=============================================
:SAVE
echo location/%location% > SavedGameState.save
echo time/%time% >> SavedGameState.save
echo b2Door/%b2Door% >> SavedGameState.save
echo b3GuardsSleep/%b3GuardsSleep% >> SavedGameState.save
echo b3GuardsAlive/%b3GuardsAlive% >> SavedGameState.save
echo d3GuardsAlive/%d3GuardsAlive% >> SavedGameState.save
echo d3Stage/%d3Stage% >> SavedGameState.save
echo chance/%chance% >> SavedGameState.save
echo hasArrows/%hasArrows% >> SavedGameState.save
echo hasBow/%hasBow% >> SavedGameState.save
echo hasRock/%hasRock% >> SavedGameState.save
echo hasKey/%hasKey% >> SavedGameState.save
echo maxInv/%maxInv% >> SavedGameState.save
echo currentInv/%currentInv% >> SavedGameState.save
for /f "tokens=1,2,3 delims==" %%a in ('set object[') do (
	echo %%a/%%b=%%c >> SavedGameState.save
)
if exist SavedGameState.save echo Save game created!
goto ACTION

::=============================================
::==               LOAD
::=============================================
:LOAD
if exist SavedGameState.save (
	for /f "tokens=1,2 delims=/" %%a in (SavedGameState.save) do (
		for /f "tokens=1,2 delims= " %%c in ("%%b") do (
			echo %%a=%%c
			set %%a=%%c
		)
	)
	)
	echo Loaded
	echo.
	goto EnterLocation%location%
) else (
	echo load failed
) 
goto ACTION

::=============================================
::==               WINGAME
::=============================================
:WINGAME
echo As you examine the chalice, you notice its extreme ornateness and
echo relize its the artifact you have been after. You question how a chalice
echo could contain the magic powers described. You start to head out of the
echo dungeon, through the way you came in. All you can think of is the large
echo pile of gold you will recieve from your employer.
echo.
echo Congratulations
pause
goto MENU

::=============================================
::==               RANDOMDEATH
::=============================================
:RANDOMDEATH
if %random% lss %chance% (
	echo You fight with all your ability but are overtaken.
	if %random% lss 16384 (
		goto DEATHEX
	) else (
		goto DEATH
	)
)

set /a chance=16384
echo You overcome the odds and survived the fierce battle.
echo.
goto %back%


::=============================================
::==               DEATHEX
::=============================================
:DEATHEX
echo You have been captured and will soon be executed. GAME OVER
goto END

::=============================================
::==               DEATH
::=============================================
:DEATH
echo You have died. GAME OVER
goto END

::=============================================
::==               ABOUT
::=============================================
:ABOUT
echo.
echo Made by: Bryan Smith
echo Date: 6/20/2011
echo Class: ITE 195
echo.
pause
goto MENU

::=============================================
::==               END
::=============================================
:END
echo.
pause




